package android.shane.com.myutils.utils;


import android.util.Log;

import java.util.Arrays;


/**
 * LogUtil
 *
 * @author shane（https://github.com/lxxgreat）
 * @version 1.0
 * @created 2016-08-11
 *
 */

public class LogUtil {
    private static final String TAG = "MyUtils";

    private static final int LOG_LEVEL = 6;

    private static final int VERBOSE = 5;
    private static final int DEBUG = 4;
    private static final int INFO = 3;
    private static final int WARN = 2;
    private static final int ERROR = 1;
    private static final int WTF = 0;

    private LogUtil() { /* Utility class */ }

    public static void v(String tag, String msg) {
        if (LOG_LEVEL > VERBOSE) {
            Log.v(TAG, tag + ":" + msg);
        }
    }

    public static void v(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > VERBOSE) {
            Log.v(TAG, tag + ":" + msg, tr);
        }
    }

    public static void d(String tag, String msg) {
        if (LOG_LEVEL > DEBUG) {
            Log.d(TAG, tag + ":" + msg);
        }
    }

    public static void d(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > DEBUG) {
            Log.d(TAG, tag + ":" + msg, tr);
        }
    }

    public static void i(String tag, String msg) {
        if (LOG_LEVEL > INFO) {
            Log.i(TAG, tag + ":" + msg);
        }
    }

    public static void i(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > INFO) {
            Log.i(TAG, tag + ":" + msg, tr);
        }
    }

    public static void w(String tag, String msg) {
        if (LOG_LEVEL > WARN) {
            Log.w(TAG, tag + ":" + msg);
        }
    }

    public static void w(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > WARN) {
            Log.w(TAG, tag + ":" + msg, tr);
        }
    }

    public static void e(String tag, String msg) {
        if (LOG_LEVEL > ERROR) {
            Log.e(TAG, tag + ":" + msg);
        }
    }

    public static void e(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > ERROR) {
            Log.e(TAG, tag + ":" + msg, tr);
        }
    }

    public static void wtf(String tag, String msg) {
        if (LOG_LEVEL > WTF) {
            Log.wtf(TAG, tag + ":" + msg);
        }
    }

    public static void wtf(String tag, String msg, Throwable tr) {
        if (LOG_LEVEL > WTF) {
            Log.wtf(TAG, tag + ":" + msg, tr);
        }
    }

    public static String logify(String privacy) {
        if (privacy == null) {
            return null;
        } else {
            char[] log = new char[privacy.length()];
            Arrays.fill(log, '*');
            return new String(log);
        }
    }
}
